
<head>
	<meta charset="utf-8" />
	<link rel="stylesheet" type="text/css" href="zhuce.css">
	<title>新用户注册 | YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证</title>
</head>
<body>
<?php

	$sex = array("1"=>"男","2"=>"女");
	$state = array("3"=>"启用","4"=>"禁用","5"=>"后台管理员");
	include("./dbconfig.php");
	$link = @mysqli_connect(HOST,USER,PASS) or die("数据库连接失败");
	mysqli_select_db($link,DBNAME);
	mysqli_set_charset($link,"utf8");
	
	//var_dump($_POST);
	//var_dump($_GET);
	
	switch($_GET['a']){ //添加
		case 'insert':
            $username = $_POST['username'];
			$name = $_POST['name'];
            $pass = $_POST['pass'];
            $sex = $_POST['sex'];
            $address = $_POST['address'];
            $code = $_POST['code'];
            $phone = $_POST['phone'];
            $email = $_POST['email'];
            $state = $_POST['state'];
            $addtime = time();
            
			
			$sql = "insert into users(username,name,pass,sex,address,code,phone,email,state,addtime) values('$username','$name','$pass','$sex','$address','$code','$phone','$email','$state','$addtime')";
		
			$result = mysqli_query($link,$sql);
			
            if(mysqli_insert_id($link)>0){
                header("Location:../denglu/denglu.php");
            }else{
                echo "添加失败";
            }
           echo mysqli_error($link);
		break;
	}
?>	
	<div id="header">
		<a href="../YOHO PJ1/index.php"><img src="nhcziuiqe112.jpg"></a>
	<div id="header">
	<div id="left">
		<img src="baida111.jpg">
	</div>
	<div id="left1">
		<img src="20120919223748_2VzQu.thumb.224_0.gif">
	</div>
	<div id="zhongxian">
		<img src="zhongxian.jpg">
	</div>
	<div id="right">
	<form action="../zhuce/zhuce.php?a=insert" method="POST">
		<input type='hidden' name='url' value='<?php echo $_SERVER['HTTP_REFERER'];?>'>
		<div id="zhanghao">
			请输入账号:<input type="text" name="username" style="width:90px" placeholder="请输入账号"><br/>
		    真实姓名:<input type="text" name="name" style="width:90px" placeholder="请输入姓名"><br/>
		</div>
		<div id="mima">
			请输入密码:<input type="password" name="pass" style="width:90px" placeholder="请输入密码"><br/>
			请输入性别:<input type="radio" name="sex" value="1" checked>男
					    <input type="radio" name="sex" value="2">女<br/>
			请输入地址:<input type="text" name="address" style="width:90px" placeholder="请输入地址"><br/>
			请输入电话:<input type="text" name="phone" style="width:90px" placeholder="请输入电话"><br/>
			请输入邮箱:<input type="text" name="email" style="width:90px" placeholder="请输入邮箱"><br/>
			<input type="hidden" name="state" value="3" checked>
			<input type="hidden" name="addtime">
		</div>
		<div id="yanzhengtext">
			输入验证码:<input type="text" name="code" style="width:100px" placeholder="请输入验证码">
		</div>
		<div id="yanzhengma">
			<img src="yanzhengma.php">
		</div>
		<div id="wenzi1">
			<input type="checkbox">
			我已阅读并同意遵守 <br/><a href="#">YOHO!BUY 有货服务条款</a>
		</div>
		
		<div id="anniu">
			<input type="submit" value="注册" style="height:45px;width:260px;background-color:red;color:white;" >
		</div>
		<div id="wenzi2">
			<a href="../denglu/denglu.php">我已注册YOHO!BUY 有货账号</a> 
		</div>
	</form>	
	<?php
		//输出错误信息		
		$_GET['errno'] = empty($_GET['errno']) ? '':$_GET['errno'];
		switch($_GET['errno']){
			case 1:
			echo "<h2 style='color:red;'>用户不存在</h2>";
			break;
			case 2:
			echo "<h2 style='color:red;'>密码错误</h2>";
			break;
			case 3:
			echo "<h2 style='color:red;'>验证码错误</h2>";
			break;
		}
	?>
	</div>
	<div id="foot">
		<a href="#"><img src="hkinczio.jpg"></a>
	</div>

</body>